<template>
	<view class="flex-col page">

	
		<view class="flex-col group_5">
			<text class="self-start text_11">收货地址</text>
			<view  class="flex-col self-stretch list list_address">
				<view class="flex-col section list-item mt-15 section_address">
					<view class="flex-row items-center self-stretch">
						<text class="font_3 text_4 ml-13">{234</text>
					</view>
					<text class="mt-10 self-start font_4 text_5">{23432</text>
					<text class="mt-10 self-center font_5 text_6">{234234}</text>
				</view>
			</view>
		</view>
		</view>
</template>

<script>
	export default {
		props: {},
		data() {
			return {
				id: undefined, // 订单ID
				jdOrderDetail: undefined, // 订单详情
				logs: [], // 订单日志
			};
		},
		onLoad(e) {
			this.id = e.id
		},
		onShow() {
			// this._jdOrderDetail()
		},
		methods: {
			goUrl(url) {
				uni.navigateTo({
					url
				})
			},
			async _jdOrderDetail() {
				uni.showLoading({
					title: ''
				})
				const res = await jdOrderDetail(this.id)
				uni.hideLoading()
				if (res.code != 200) {
					uni.showModal({
						content: res.msg,
						showCancel: false,
						success: () => {
							uni.navigateBack()
						}
					})
					return
				}
				this.jdOrderDetail = res.data
				this.logs = []
				res.data.logs.forEach(ele => {
					if(ele.type == 1 || ele.type == 3 || ele.type == 4) {
						this.logs.push(ele)
					} else if(ele.type == 2) {
						// 发货只需要保留一条
						const _log = this.logs.find(_ele => _ele.type == 2)
						if(!_log) {
							this.logs.push(ele)
						}
					}
				})
			},
			async pay() {
				uni.showLoading({
					title: ''
				})
				const res = await orderPay({
					orderNo: [this.jdOrderDetail.orderInfo.orderNumber],
					payMethod: 0,
				})
				uni.hideLoading()
				if (res.code == 200) {
					const param = JSON.parse(res.data.payRequest)
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: param.timeStamp,
						nonceStr: param.nonceStr,
						package: param.package,
						signType: param.signType,
						paySign: param.paySign,
						success: (success) => {
							console.log(success)
							uni.showModal({
								content: "支付成功",
								showCancel: false,
								success: (res) => {
									this._jdOrderDetail()
								},
							});
						},
						fail: (fail) => {
							// uni.showModal({
							// 	content: JSON.stringify(fail),
							// 	showCancel: false
							// })
							console.error(fail)
						},
					});
				} else {
					uni.showModal({
						content: res.msg,
						showCancel: false
					})
				}
			},
			async close() {
				uni.showModal({
					content: '确定要关闭订单吗？',
					success: async (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: ''
							})
							const res = await jdOrderClose({
								orderId: this.jdOrderDetail.orderInfo.id,
							})
							uni.hideLoading()
							if (res.code == 200) {
								this._jdOrderDetail()
							} else {
								uni.showToast({
									title: res.msg,
									icon: 'none'
								})
							}
						}
					}
				})
				
			},
			async jdOrderCloseVop() {
				uni.showModal({
					content: '确定要取消订单吗？',
					success: async (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: ''
							})
							const res = await jdOrderCloseVop({
								jdOrderId: this.jdOrderDetail.orderInfo.orderNumberOuter,
							})
							uni.hideLoading()
							if (res.code == 200) {
								uni.showModal({
									content: "已提交取消订单申请，请等待平台审核",
									showCancel: false,
									success: (res) => {
										this._jdOrderDetail()
									},
								});
								this._jdOrderDetail()
							} else {
								uni.showToast({
									title: res.msg,
									icon: 'none'
								})
							}
						}
					}
				})
				
			},
			orderLogisticsShippers(item) {
				uni.setStorageSync('orderLogisticsShippers', item)
				const orderLogisticsShipperLogs = this.jdOrderDetail.orderLogisticsShipperLogs.filter(ele => ele.logisticsShipperId == item.id)
				uni.setStorageSync('orderLogisticsShipperLogs', orderLogisticsShipperLogs)
				uni.navigateTo({
					url: '/packageJD/logistics'
				})
			},
			async jdOrderDelivery() {
				uni.showModal({
					content: '确定已收到商品，并将订单设置为已收货？',
					success: async (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: ''
							})
							const res = await jdOrderDelivery({
								orderId: this.jdOrderDetail.orderInfo.id,
							})
							uni.hideLoading()
							if (res.code == 200) {
								this._jdOrderDetail()
							} else {
								uni.showToast({
									title: res.msg,
									icon: 'none'
								})
							}
						}
					}
				})
				
			},
			evaluate() {
				uni.setStorageSync('jdOrderDetail', this.jdOrderDetail)
				uni.navigateTo({
					url: '/packageJD/evaluate'
				})
			},
		}
	};
</script>

<style scoped lang="scss">
	// @import "@/static/jd/base.scss";

	.ml-3 {
		margin-left: 6rpx;
	}

	.mt-53 {
		margin-top: 106rpx;
	}

	.mt-21 {
		margin-top: 42rpx;
	}

	.ml-9 {
		margin-left: 18rpx;
	}

	.mt-11 {
		margin-top: 22rpx;
	}

	.page {
		padding: 0 36rpx 80rpx 56rpx;
		background-color: #ffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.image {
		width: 48rpx;
		height: 44rpx;
	}

	.pos {
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
	}

	.text {
		color: #000000;
		font-size: 40rpx;
		font-family: Laila;
		font-weight: 700;
		line-height: 37.4rpx;
	}

	.group {
		margin-top: 64rpx;
	}

	.order_id {
		width: 300rpx;
	}

	.text-wrapper {
		padding: 40rpx 0 96rpx;
		background-color: #fbfbfd;
		border-radius: 32rpx;
		width: 202rpx;
	}

	.font {
		font-size: 28rpx;
		font-family: Mukta;
		line-height: 25.88rpx;
		font-weight: 700;
		color: #2d3142;
	}

	.text_2 {
		line-height: 26.18rpx;
	}

	.font_2 {
		font-size: 32rpx;
		font-family: Mukta;
		line-height: 30.24rpx;
		color: #2d3142;
	}

	.order-text {
		font-size: 28rpx;
	}

	.text_5 {
		line-height: 25.4rpx;
	}

	.pos_2 {
		position: absolute;
		right: 0;
		bottom: 43.04rpx;
	}

	.section {
		margin-right: 20rpx;
		padding: 30rpx;
		background-color: #fbfbfd;
		border-radius: 32rpx;
		height: 162rpx;
	}
	.section_address{
		height: auto;
	}

	.text_3 {
		line-height: 26.66rpx;
	}

	.text_4 {
		line-height: 29.6rpx;
	}

	.group_3 {
		margin-top: 50rpx;
	}

	.step_left {
		width: 48rpx;
		height: 476rpx;
	}

	.image_3 {
		border-radius: 20rpx;
		width: 82rpx;
		height: 82rpx;
	}

	.font_3 {
		font-size: 32rpx;
		font-family: Mukta;
		line-height: 30.24rpx;
		font-weight: 700;
		color: #2d3142;
	}
	
	.list_address{
		margin: 30rpx 0 0 0;
	}

	
	.text_6 {
		line-height: 30.2rpx;
	}
	.section_address .text_6 {
		line-height: 40rpx;
	}

	.font_4 {
		font-size: 28rpx;
		font-family: Mukta;
		line-height: 25.88rpx;
		color: #9c9db9;
	}

	.text_7 {
		line-height: 25.9rpx;
	}

	.text_8 {
		line-height: 25.9rpx;
	}

	.font_5 {
		font-size: 32rpx;
		font-family: Mukta;
		line-height: 30.24rpx;
		font-weight: 700;
		color: #9c9eb9;
	}

	.text_9 {
		line-height: 30.36rpx;
	}

	.text_10 {
		line-height: 29.98rpx;
	}

	.group_4 {
		margin-right: 12rpx;
		margin-top: 48rpx;
	}

	.group_5 {
		margin-top: 64rpx;
	}

	.text_11 {
		color: #2d3142;
		font-size: 36rpx;
		font-family: Mukta;
		font-weight: 700;
		line-height: 33.98rpx;
	}

	.list-item {
		margin-right: 20rpx;
	}

	.list-item:first-child {
		margin-top: 0;
	}

	.section_2 {
		padding: 4rpx 16rpx;
		background-color: #f4f6fa;
		border-radius: 32rpx;
	}

	.image_4 {
		width: 106rpx;
		height: 138rpx;
	}

	.text_12 {
		line-height: 26.38rpx;
	}

	.font_7 {
		font-size: 24rpx;
		font-family: Mukta;
		line-height: 17.78rpx;
		color: #2d3142;
	}

	.text-wrapper_2 {
		padding: 16rpx 0;
		background-color: #dde2f080;
		border-radius: 14rpx;
		width: 44rpx;
		height: 44rpx;
		margin-top: 80rpx !important;
	}

	.view {
		margin-right: 26rpx;
		margin-top: 30rpx;
	}

	.font_6 {
		font-size: 24rpx;
		font-family: Mukta;
		line-height: 15.36rpx;
		color: #9c9db9;
	}

	.group_6 {
		margin-top: 56rpx;
	}

	.text_15 {
		line-height: 29.56rpx;
	}

	.text_16 {
		margin-right: 16rpx;
		line-height: 20.16rpx;
	}

	.group_7 {
		margin-top: 48rpx;
	}

	.text_17 {
		line-height: 29.72rpx;
	}

	.text_18 {
		margin-right: 16rpx;
		line-height: 23.62rpx;
	}

	.group_8 {
		margin-top: 48rpx;
	}

	.text_19 {
		line-height: 29.66rpx;
	}

	.text_20 {
		margin-right: 16rpx;
	}
	.order-detail-text {
		width: 450rpx;
		line-height: 34rpx;
	}
	.order-detail-text-more{
		font-size:28rpx
	}
	.btn-group {
		display: flex;
		margin-top: 32rpx;
		.item {
			flex: 1;
			padding: 0 32rpx;
		}
	}
	.orderLogisticsShippers {
		padding-top: 32rpx;
	}
</style>